﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Pantry.DataAccess;
using Pantry.Commons;
namespace Pantry.UnitTest
{
    [TestFixture]
    public class TestGovOfficeRegionDao
    {
        private GovOfficeRegionDao _govOfficeRegionDao;

        private const string SqlConnectiosnString =
            //ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString;
            "Server=10.16.102.126;Database=Pantry_MockProject;Integrated Security=True;";
        [Test]
        public void TestGetGovOfficeRegionById_Input_InvalidId_Return_Null()
        {
            _govOfficeRegionDao = new GovOfficeRegionDao(SqlConnectiosnString);
            const int invalidId = 0;
            const int expectedResult = 0;
            Assert.AreEqual(_govOfficeRegionDao.GetGovOfficeRegionById(invalidId).Rows.Count,expectedResult);
        }
        [Test]
        public void TestGetGovOfficeRegionById_Input_ValidId_Return_DataTable()
        {
            _govOfficeRegionDao = new GovOfficeRegionDao(SqlConnectiosnString);
            const int invalidId = 5;
            const int expectedResult = 1;
            Assert.AreEqual(_govOfficeRegionDao.GetGovOfficeRegionById(invalidId).Rows.Count, expectedResult);
        }
        [Test]
        [ExpectedException(typeof(FormatException))]
        public void TestGetGovOfficeRegionById_Input_InvalidIdNotANumber_Return_Exception()
        {
            _govOfficeRegionDao = new GovOfficeRegionDao(SqlConnectiosnString);
            const string invalidId = "a";
            const int expectedResult = 0;
            Assert.AreEqual(_govOfficeRegionDao.GetGovOfficeRegionById(int.Parse(invalidId)).Rows.Count, expectedResult);
        }

    }
}
